<template>
  <a-layout-sider width="200" style="background: #fff">
    <a-menu
        v-model:selectedKeys="selectedKeys"
        v-model:openKeys="openKeys"
        mode="inline"
        :style="{ height: '100%', borderRight: 0 }"
    >
      <a-menu-item key="/welcome">
        <router-link to="/welcome">
          <coffee-outlined/>&nbsp;欢迎
        </router-link>
      </a-menu-item>
      <a-menu-item key="/about">
        <router-link to="/about">
          <coffee-outlined/>&nbsp;关于
        </router-link>
      </a-menu-item>
    </a-menu>
  </a-layout-sider>

</template>

<script>
// //vue2 写法
// export default {
//   name: 'HelloWorld',
//   props: {
//     msg: String
//   }
// }

import {defineComponent, ref, watch} from 'vue';
import router from "@/router";

export default defineComponent({
  name: "the-sider-view",
  setup() {
    const selectedKeys = ref([]);
    watch(() => router.currentRoute.value.path, (newValue) => {
      console.log('watch', newValue);
      selectedKeys.value = [];
      selectedKeys.value.push(newValue);
    }, {immediate: true})
    return {
      selectedKeys
    };
  },
});
</script>
<!--scoped 当前页面生效-->
<style scoped>

</style>
